package br.ufrj.dcc.tp.cliente.controller;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JOptionPane;

public class CloseListener extends WindowAdapter {
	
	ClientController controller;
	
	public CloseListener(ClientController controller){
		this.controller = controller;
	}
	@Override
	public void windowClosing(WindowEvent e) {
		int response = JOptionPane.showConfirmDialog(null ,"Deseja sair?", "Saída",JOptionPane.YES_NO_OPTION);
		if(response == JOptionPane.YES_OPTION) {
			e.getWindow().setVisible(false);
			controller.finish();
		}
	}
}
